{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "# Ch `03`: Concept `02`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Polynomial regression"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Import the relevant libraries and initialize the hyper-parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "learning_rate = 0.01\n",
    "training_epochs = 40"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Set up some fake raw input data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "trX = np.linspace(-1, 1, 101)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Set up raw output data based on a degree 6 polynomial"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "num_coeffs = 6\n",
    "trY_coeffs = [1, 2, 3, 4, 5, 6]\n",
    "trY = 0\n",
    "for i in range(num_coeffs):\n",
    "    trY += trY_coeffs[i] * np.power(trX, i)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Add some noise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "trY += np.random.randn(*trX.shape) * 1.5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Plot the raw data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEACAYAAAC08h1NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHKVJREFUeJzt3X+Q3Hd93/Hn2+jutOh0kkwOm2J650KM3AHFyCNCCx2v\nqEUMkxm7bovrltaEG2LHQIinU1AgE4k6eIAZ7AkpmphyidwUyabMFGyCEVatTcZJzN3oh2VHsmMP\nrMDY1m0brFr0ZAnz7h+7e9rb++7ud7/f7+73u/t9PWZ2vLu3+/1+vrvW6/vZ9/fz/XzN3RERkfy4\nIO0GiIhIfyn4RURyRsEvIpIzCn4RkZxR8IuI5IyCX0QkZ2IHv5ldYmYPm9nfmtnjZvax2vM7zOxZ\nMztUu10Tv7kiIhKXxR3Hb2YXAxe7+xEzGwcOAtcCNwAvufud8ZspIiJJWRV3Ae7+AvBC7f5pMzsO\nvL72Z4u7fBERSVaiNX4zmwauAL5fe+ojZnbEzL5qZuuSXJeIiESTWPDXyjzfAD7u7qeBXcAb3f0K\nqr8IVPIREcmA2DV+ADNbBXwbeNDd/zDg71PAA+6+KeBvmixIRCQCd49UTk+qx/8nwLHG0K8d9K27\nHnii1ZvdfWhvO3bsSL0N2j5tX962LQ/bF0fsg7tm9k7g3wGPm9lhwIFPAf/WzK4AfgGUgZvjrktE\nROJLYlTPXwGvCvjTd+MuW0REkqczd3usWCym3YSe0vYNrmHeNhj+7YsjkYO7sRpg5mm3QURk0JgZ\nnvLBXRERGRAKfhGRnFHwi4jkjIJfRCRnFPwiIjmj4BcRyRkFv4hIzij4RURyRsEvIpIzCn4RkZxR\n8IuI5IyCX0SGTqVSYX5+nkqlknZTMknBLyJDZe/e+5ia2si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ag6SJ3P2lmFwMLLZZR//5+aGYl4G1AFoM/zHfx\nLPAG4DkzexUw4e5/36f2xdVx+9y9sZTwVeALfWhXv/yE6ndXl6l/a3G5++mG+w+a2S4zu7DT/59p\nl3oCe05m9mozG6/dXwO8B3iinw1LSKue4TzwJjObMrNR4N9Q7XUNgvuBD9bu3wR8q/kFZra+tl2Y\n2S8B/5TqOR1ZFOa7eIDqtgL8a6oH7gdFx+2r7cDrriW731UrRut/a/cD/wHAzN4BvFgvVQ6QltvX\neLzCzN5OdYh+505JCkepr6Nac1sEngcerD3/OuDbtfuXUh19cJjq1M/b0z66nuT21R5fAzxFdebS\nQdq+C4H9tbZ/D1hfe/5K4Cu1+/8EOFr7/h4DPph2uzts04rvAvgM8Ou1+2NUT0h8GngUmE67zQlv\n3x1UO1aHgf8FXJZ2m7vYtj3Ac8DLwI+A3wBuBn6z4TX/herIpsdoM5Iwi7dO2wd8pOG7+2vgV8Ms\nVydwiYjkTNqlHhER6TMFv4hIzij4RURyRsEvIpIzCn4RkZxR8IuI5IyCX0QkZxT8IiI58/8BOnW7\nA5QzmbgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f0cf09fef98>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(trX, trY)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Define the nodes to hold values for input/output pairs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "X = tf.placeholder(\"float\")\n",
    "Y = tf.placeholder(\"float\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Define our polynomial model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "def model(X, w):\n",
    "    terms = []\n",
    "    for i in range(num_coeffs):\n",
    "        term = tf.multiply(w[i], tf.pow(X, i))\n",
    "        terms.append(term)\n",
    "    return tf.add_n(terms)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Set up the parameter vector to all zero"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "w = tf.Variable([0.] * num_coeffs, name=\"parameters\")\n",
    "y_model = model(X, w)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Define the cost function just as before"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "cost = tf.reduce_sum(tf.square(Y-y_model))\n",
    "train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Set up the session and run the learning algorithm just as before"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 1.10158885  2.36433625  3.30378437  4.43473864  3.75751448  4.60356045]\n"
     ]
    }
   ],
   "source": [
    "sess = tf.Session()\n",
    "init = tf.global_variables_initializer()\n",
    "sess.run(init)\n",
    "\n",
    "for epoch in range(training_epochs):\n",
    "    for (x, y) in zip(trX, trY):\n",
    "        sess.run(train_op, feed_dict={X: x, Y: y})\n",
    "\n",
    "w_val = sess.run(w)\n",
    "print(w_val)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Close the session when done"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "sess.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Plot the result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEACAYAAAC08h1NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYVOWZ9/HvLfRS0DSLaZUIdrkhOkoABzVqYmNE0ZhR\nY9SYN1ET3DUxiXE0OiM4TBI10Yy+hjGOHZcYWtSZRCEqitITd4hsKuLySrVLlC5F0CYtNHC/f1R1\nU91Ud9e+/j7XVRdVp87ynCr6Pk/dz3LM3RERkfKxQ74LICIiuaXALyJSZhT4RUTKjAK/iEiZUeAX\nESkzCvwiImUm7cBvZqPM7Ekze8XMXjKz70eXTzezd81sSfQxNf3iiohIuizdfvxmtguwi7svM7Ma\n4EXgBOA04FN3vzH9YoqISKYMTHcH7v4B8EH0eZuZvQrsGn3b0t2/iIhkVkZz/GYWBMYDL0QXXWRm\ny8zsdjMbmsljiYhIajIW+KNpngeAS9y9DZgF7Onu44n8IlDKR0SkAKSd4wcws4HAPOARd78pzvv1\nwFx3HxfnPU0WJCKSAndPKZ2eqRr/74CVsUE/2ujb6evAy71t7O4l+5g+fXrey6Dz0/mV27mVw/ml\nI+3GXTM7DPg/wEtmthRw4ErgW2Y2HtgKhIDz0j2WiIikLxO9ep4BBsR569F09y0iIpmnkbtZ1tDQ\nkO8iZJXOr3iV8rlB6Z9fOjLSuJtWAcw832UQESk2ZobnuXFXRESKhAK/iEiZUeAXESkzCvwiImVG\ngV9EpMwo8IuIlBkFfhGRMqPALyJSZhT4RUT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2qAAAAAElFTkSu\nQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f0cf0839898>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(trX, trY)\n",
    "trY2 = 0\n",
    "for i in range(num_coeffs):\n",
    "    trY2 += w_val[i] * np.power(trX, i)\n",
    "plt.plot(trX, trY2, 'r')\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
